Skip to content

Configure OpenAI-compatible model providers - #1

Merged
jonbotx merged 1 commit into
masterfrom
provider-config
Nov 24, 2026
Merged

jonbotx merged 1 commit into
masterfrom
provider-config

Conversation

@jonbotx

@jonbotx jonbotx commented Nov 24, 2026

Copy link
Copy Markdown
Owner

What and why

The packaged OpenCode 2.4.1 web interface has no provider screen, so there was no way to point the service at a model without shelling into the container. This adds a Configure Model Providers action that connects any OpenAI-compatible endpoint — a self-hosted vLLM, LM Studio, or Ollama server, or a hosted API such as OpenRouter.

For each provider the action writes an entry into OpenCode's own config on the main volume, and keeps the API key on the startos volume, handed to the server as an OPENCODE_KEY_<ID> environment variable and referenced from the config as {env:OPENCODE_KEY_<ID>}. Nothing Secret is written to the config file.

Bumps 2.4.1:0 → 2.4.1:1. No migration: the change is an added optional key.

Files

  • startos/fileModels/opencode.json.ts — tolerant model of main/.config/opencode/opencode.json (z.looseObject, unknown keys preserved).
  • startos/fileModels/store.json.ts — adds providerKeys.
  • startos/actions/configureProviders.ts — one repeatable provider list (id, name, base URL, optional key, models, default toggle).
  • startos/main.ts — injects each stored key reactively (a key change restarts the server; a provider-only change is picked up by OpenCode's live config reload).
  • startos/utils.ts, actions/index.ts, i18n in 5 locales, README/instructions/AGENTS.

Verification

Installed the CI-built x86_64 package on a StartOS 0.4.2 box and drove the action through start-cli:

  • The generated form spec is a repeatable object list with displayAs: name / uniqueBy: id, and prefills from the configured providers including their keys.
  • Adding a provider writes the expected entry to opencode.json and its key to store.json; the running opencode process (PID 3) carries OPENCODE_KEY_<ID> in /proc/3/environ, and the server's /api/provider and /api/model list the provider with the resolved key.
  • Adding two providers works; API keys are optional (a keyless provider registers with no apiKey and no env var).
  • Removing a provider deletes both its config entry and its stored key; a default pointing at a removed provider is dropped, and an empty list disconnects all providers.
  • Hand-edited keys the package does not own (theme, autoupdate) survive a save.
  • tsc --noEmit and Prettier are clean; both arches build in CI.

OpenRouter's own model fetch and a keyless local provider were exercised, so the config is accepted by the real server, not just by the schema.

The packaged OpenCode 2.4.1 web interface has no provider screen, so there was
no way to point the service at a model without shelling into the container.

Add a Configure Model Providers action that writes provider entries into
OpenCode's own config on the main volume, and keeps each provider's API key on
the startos volume, passed to the server as OPENCODE_KEY_<ID>.
@jonbotx
jonbotx merged commit f5bc149 into master Nov 24, 2026
6 checks passed
@jonbotx
jonbotx deleted the provider-config branch November 24, 2026 23:13
jonbotx added a commit that referenced this pull request Nov 25, 2026
Addresses the review on #2.

- The action now owns only the providers it wrote: the `opencode.json`
  entries carrying `package: @opencode/ai/providers/openai-compatible`.
  It prefills and rebuilds those, and copies every other entry — and a
  `model` that names none of them — through untouched. `model` is now
  changed only when a Default is set or when it names a managed provider
  this save removes, so saving with nothing ticked no longer clears a
  model set to something else.
- Docs: the served 2.4.1 web app does have Settings → Providers (the
  catalog lists 334 providers, and OpenCode ships a free default model).
  Restore the audit's step 4 and correct the "no provider screen" claims
  in `instructions.md` and `README.md`: hosted providers connect in the
  app, and this action is for OpenAI-compatible endpoints the catalog
  cannot reach.
- Restore claims #1 had already removed: the image is pinned by tag and
  digest; drop "nothing upstream is disabled or skipped" (the self-updater
  is off), the warning restatement, and the StartOS address parenthetical.
- Trim AGENTS.md to rules: drop the generic "Working here" block, the port
  bullet, and the image-pin bullet, and add the scoping rule for the action.
- Cut the new comments to one fact each.
jonbotx pushed a commit that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant